import request from '@/utils/request';

// 更新图片
export function uploadImage(file: File) {
    const formData = new FormData();
    formData.set('image', file);

    return request<string>('/upload/image', {
        data: formData,
        method: 'POST',
        headers: {'Content-Type': 'multipart/form-data'},
    });
}

// 检查视频是否上传，上传视频
export function uploadCheck(data: { type: string; hash: string }) {
    return request<{ uploadedBytes: number }>('/upload/check', {
        data,
        method: 'POST',
        headers: {'Content-Type': 'application/json'},
    });
}

// 视频断点续传
export function uploadChunk(formData: FormData) {
    return request<{ uploadedBytes: number }>('/upload/chunk', {
        data: formData,
        method: 'POST',
        headers: {'Content-Type': 'multipart/form-data'},
    });
}

// 视频上传华为云
export function uploadHWYun(data: {
    title: string;
    type: string;
    episodeId: number;
}) {
    return request('/upload/hwcloud', {
        data,
        method: 'POST',
    });
}

